//
//  YBMineCell.swift
//  Moonlight
//
//  Created by Penlon Kim on 2023/6/9.
//  Copyright © 2023 Moonlight Game Streaming Project. All rights reserved.
//

import UIKit
import SnapKit

class YBMineCell: UITableViewCell {
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        contentView.addSubviews([imgView, kTitleLabel, arrowImgView])
        
        imgView.snp.makeConstraints { make in
            make.size.equalTo(UIDevice.bk_isiPhone ? 18 : 30)
            make.centerY.equalToSuperview()
            make.left.equalTo(18)
            make.top.bottom.equalToSuperview().inset(UIDevice.bk_isiPhone ? 14 : 20)
        }
        
        kTitleLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(imgView.snp.right).offset(11)
        }
        
        arrowImgView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(-20)
            make.size.equalTo(UIDevice.bk_isiPhone ? CGSizeMake(9, 15) : CGSizeMake(16, 24))
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - lazy
    private lazy var imgView: UIImageView = {
        let iv = UIImageView()
        iv.contentMode = .scaleAspectFill
        iv.clipsToBounds = true
        return iv
    }()
    
    private lazy var kTitleLabel = self.bk_addLabel(font: .systemFont(ofSize: UIDevice.bk_isiPhone ? 14 : 16), bgColor: .clear, textColor: .lightBlack51DarkLight230)
    
    private lazy var arrowImgView = UIImageView(image: UIImage(named: "icon_arrow_right_gray"))
    
}

// MARK: - Public
extension YBMineCell {
    
    func updateCell(by type: YBMineVC.RowType) {
        imgView.image = UIImage(named: type.style.icon)
        kTitleLabel.text = type.style.des
    }
    
}
